package com.cc.openeye.find

import com.cc.openeye.base.BasePager
import com.cc.openeye.find.item.ItemTypeHelper
import com.cc.openeye.find.item.ItemViewType.CARD_AUTHER
import com.cc.openeye.find.item.ItemViewType.COLUMN_CARD_LIST
import com.cc.openeye.find.item.ItemViewType.TAG_BRIEFCARD
import com.cc.openeye.find.item.ItemViewType.TEXT_CARD_HEADER7
import com.cc.openeye.find.item.cardAuther.CardAuther
import com.cc.openeye.find.item.columnCardList.ColumnCardList
import com.cc.openeye.find.item.tagBriefCard.TagBriefCard
import com.cc.openeye.find.item.textCardHeader7.TextCardHeader7
import com.tencent.kuikly.compose.extension.NestedScrollMode
import com.tencent.kuikly.compose.extension.nestedScroll
import com.tencent.kuikly.compose.foundation.layout.Column
import com.tencent.kuikly.compose.foundation.layout.padding
import com.tencent.kuikly.compose.foundation.lazy.LazyColumn
import com.tencent.kuikly.compose.foundation.lazy.itemsIndexed
import com.tencent.kuikly.compose.setContent
import com.tencent.kuikly.compose.ui.Modifier
import com.tencent.kuikly.compose.ui.unit.dp
import com.tencent.kuikly.core.annotations.Page
import com.tencent.kuikly.core.nvi.serialization.json.JSONObject


@Page("openEyeFindPage", supportInLocal = true)
internal class OpenEyeFindPage : BasePager() {


    private val openEyeFindViewModel by lazy {
        OpenEyeFindViewModel.newInstance()
    }

    override fun onCreatePager(pagerId: String, pageData: JSONObject) {
        super.onCreatePager(pagerId, pageData)
        println("====>pagerId:${pagerId}")
    }

    override fun willInit() {
        super.willInit()

        setContent {
            Column(modifier = Modifier.padding(top = (pageData.statusBarHeight).dp)) {

                LazyColumn {
                    itemsIndexed(openEyeFindViewModel.findData.value.itemList) { index, item ->
                        println("====>itemTYpe:${ItemTypeHelper.getItemViewType(item)}")
                        when (ItemTypeHelper.getItemViewType(item)) {
                            TEXT_CARD_HEADER7 -> {
                                TextCardHeader7(item)
                            }

                            TAG_BRIEFCARD -> {
                                TagBriefCard(item)
                            }

                            COLUMN_CARD_LIST -> {
                                ColumnCardList(item)
                            }

                            CARD_AUTHER -> {
                                CardAuther(item, index)
                            }
                        }
                    }
                }
            }
        }
    }
}



